Integrate feed-specific setup into general setup
authorPatrick Westerhoff <PatrickWesterhoff@gmail.com>
Thu, 19 Dec 2013 17:16:49 +0000 (18:16 +0100)
committerPatrick Westerhoff <PatrickWesterhoff@gmail.com>
Thu, 19 Dec 2013 17:16:49 +0000 (18:16 +0100)
The special page setup was previously handled separately for feed output
to restrict the request arguments to a small subset of possible filter
options. This behavior was removed in 52b59f0685.

This makes the main difference between the normal and the feed setup that
custom filter options were not loaded for feed output. Support for custom
filter options was introduced with fcbdd58326 but did not touch the feed
setup, preventing filters from being initialized when requesting a feed
(see bug 57201).

After adding support for custom filters to the feed setup, the only
remaining difference is a different default limit, and the support for
subpage syntax for non-feed output.

This commit merges the feed setup with the standard setup.

Furthermore, in `SpecialRecentchangeslinked`, the extra argument parsing
was made also redundant with 52b59f0685.

Bug: 57201
Change-Id: Ia8ba28efb96da9df5d7252278d46ff88a143368c

RELEASE-NOTES-1.23
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialRecentchangeslinked.php

index 783ca3c..59e43a1 100644 (file)
@@ -73,6 +73,7 @@ production.
 * (bug 57098) SpecialPasswordReset now obeys returnto parameter
 * (bug 37812) ResourceLoader will notice when a module's definition changes and
   recompile it accordingly.
+* (bug 57201) SpecialRecentChangesFilters hook is now executed for feeds
 
 === API changes in 1.23 ===
 * (bug 54884) action=parse&prop=categories now indicates hidden and missing
@@ -83,6 +84,7 @@ production.
 * action=parse&prop=languageshtml was deprecated in 1.18 and will be removed in
   MediaWiki 1.24.
 * action=parse now has disabletoc flag to disable table of contents in output.
+* SpecialRecentChanges::feedSetup() was removed.
 
 === Languages updated in 1.23===
 
index 3b121fb..f866158 100644 (file)
@@ -30,6 +30,14 @@ class SpecialRecentChanges extends IncludableSpecialPage {
        var $rcOptions, $rcSubpage;
        protected $customFilters;
 
+       /**
+        * The feed format to output as (either 'rss' or 'atom'), or null if no
+        * feed output was requested
+        *
+        * @var string $feedFormat
+        */
+       protected $feedFormat;
+
        public function __construct( $name = 'Recentchanges' ) {
                parent::__construct( $name );
        }
@@ -69,10 +77,11 @@ class SpecialRecentChanges extends IncludableSpecialPage {
         * Create a FormOptions object with options as specified by the user
         *
         * @param array $parameters
-        *
         * @return FormOptions
         */
        public function setup( $parameters ) {
+               global $wgFeedLimit;
+
                $opts = $this->getDefaultOptions();
 
                foreach ( $this->getCustomFilters() as $key => $params ) {
@@ -86,7 +95,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                        $this->parseParameters( $parameters, $opts );
                }
 
-               $opts->validateIntBounds( 'limit', 0, 5000 );
+               $opts->validateIntBounds( 'limit', 0, $this->feedFormat ? $wgFeedLimit : 5000 );
 
                return $opts;
        }
@@ -105,31 +114,12 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                return $this->customFilters;
        }
 
-       /**
-        * Create a FormOptions object specific for feed requests and return it
-        *
-        * @return FormOptions
-        */
-       public function feedSetup() {
-               global $wgFeedLimit;
-               $opts = $this->getDefaultOptions();
-               $opts->fetchValuesFromRequest( $this->getRequest() );
-               $opts->validateIntBounds( 'limit', 0, $wgFeedLimit );
-
-               return $opts;
-       }
-
        /**
         * Get the current FormOptions for this request
         */
        public function getOptions() {
                if ( $this->rcOptions === null ) {
-                       if ( $this->including() ) {
-                               $isFeed = false;
-                       } else {
-                               $isFeed = (bool)$this->getRequest()->getVal( 'feed' );
-                       }
-                       $this->rcOptions = $isFeed ? $this->feedSetup() : $this->setup( $this->rcSubpage );
+                       $this->rcOptions = $this->setup( $this->rcSubpage );
                }
 
                return $this->rcOptions;
@@ -142,12 +132,12 @@ class SpecialRecentChanges extends IncludableSpecialPage {
         */
        public function execute( $subpage ) {
                $this->rcSubpage = $subpage;
-               $feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' );
+               $this->feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' );
 
                # 10 seconds server-side caching max
                $this->getOutput()->setSquidMaxage( 10 );
                # Check if the client has a cached version
-               $lastmod = $this->checkLastModified( $feedFormat );
+               $lastmod = $this->checkLastModified( $this->feedFormat );
                if ( $lastmod === false ) {
                        return;
                }
@@ -168,7 +158,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                        return;
                }
 
-               if ( !$feedFormat ) {
+               if ( !$this->feedFormat ) {
                        $batch = new LinkBatch;
                        foreach ( $rows as $row ) {
                                $batch->add( NS_USER, $row->rc_user_text );
@@ -177,8 +167,8 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                        }
                        $batch->execute();
                }
-               if ( $feedFormat ) {
-                       list( $changesFeed, $formatter ) = $this->getFeedObject( $feedFormat );
+               if ( $this->feedFormat ) {
+                       list( $changesFeed, $formatter ) = $this->getFeedObject( $this->feedFormat );
                        /** @var ChangesFeed $changesFeed */
                        $changesFeed->execute( $formatter, $rows, $lastmod, $opts );
                } else {
index afd5b4e..1c3e05c 100644 (file)
@@ -44,12 +44,6 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
                $opts['target'] = $par;
        }
 
-       public function feedSetup() {
-               $opts = parent::feedSetup();
-               $opts['target'] = $this->getRequest()->getVal( 'target' );
-               return $opts;
-       }
-
        public function getFeedObject( $feedFormat ) {
                $feed = new ChangesFeed( $feedFormat, false );
                $feedObj = $feed->getFeedObject(